package com.athuiju.hr.controller.front;


import com.athuiju.commonutils.R;
import com.athuiju.hr.entity.VisitPerson;
import com.athuiju.hr.service.VisitPersonService;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author wzh
 * @since 2022-01-02
 */
@RestController
@RequestMapping("/hr/visit-person")
@Api(value="小程序添加列表controller",tags={"小程序添加列表操作接口"})
public class VisitPersonController {
    @Autowired
    public VisitPersonService visitPersonService;

    @ApiOperation(value = "查询全部数据controller")
    @GetMapping("visitPersonAll")
    @ApiResponses({@ApiResponse(code = 200,message = "OK",response = VisitPerson.class),
    })
    public R visitPersonAll(){
        List<VisitPerson> visitPersonAll=visitPersonService.getVisitPersonAll();
        return  R.ok().data("visitPersonAll",visitPersonAll);
    }


    @ApiOperation(value = "添加到访记录controller")
    @PostMapping("addVisitPerson")
    @ApiResponses({@ApiResponse(code = 200,message = "OK",response = VisitPerson.class),
    })
    public R addVisitPerson(
            @ApiParam(name = "hr", value = "人员对象", required = true)
            @RequestBody VisitPerson visitPerson) {
        boolean save = visitPersonService.save(visitPerson);

        if (save) {
            return R.ok();
        } else {
            return R.error();
        }
    }


}

